package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallStorage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallStorageMapper {
    @Delete({
        "delete from haogoumall_storage",
        "where storage_id = #{storageId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer storageId);

    @Insert({
        "insert into haogoumall_storage (storage_id, storage_key, ",
        "storage_name, storage_type, ",
        "storage_size, storage_url, ",
        "storage_add_time, storage_update_time, ",
        "storage_deleted)",
        "values (#{storageId,jdbcType=INTEGER}, #{storageKey,jdbcType=VARCHAR}, ",
        "#{storageName,jdbcType=VARCHAR}, #{storageType,jdbcType=VARCHAR}, ",
        "#{storageSize,jdbcType=INTEGER}, #{storageUrl,jdbcType=VARCHAR}, ",
        "#{storageAddTime,jdbcType=TIMESTAMP}, #{storageUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{storageDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallStorage record);

    @InsertProvider(type=HaogoumallStorageSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallStorage record);

    @Select({
        "select",
        "storage_id, storage_key, storage_name, storage_type, storage_size, storage_url, ",
        "storage_add_time, storage_update_time, storage_deleted",
        "from haogoumall_storage",
        "where storage_id = #{storageId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="storage_id", property="storageId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="storage_key", property="storageKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="storage_name", property="storageName", jdbcType=JdbcType.VARCHAR),
        @Result(column="storage_type", property="storageType", jdbcType=JdbcType.VARCHAR),
        @Result(column="storage_size", property="storageSize", jdbcType=JdbcType.INTEGER),
        @Result(column="storage_url", property="storageUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="storage_add_time", property="storageAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="storage_update_time", property="storageUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="storage_deleted", property="storageDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallStorage selectByPrimaryKey(Integer storageId);

    @UpdateProvider(type=HaogoumallStorageSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallStorage record);

    @Update({
        "update haogoumall_storage",
        "set storage_key = #{storageKey,jdbcType=VARCHAR},",
          "storage_name = #{storageName,jdbcType=VARCHAR},",
          "storage_type = #{storageType,jdbcType=VARCHAR},",
          "storage_size = #{storageSize,jdbcType=INTEGER},",
          "storage_url = #{storageUrl,jdbcType=VARCHAR},",
          "storage_add_time = #{storageAddTime,jdbcType=TIMESTAMP},",
          "storage_update_time = #{storageUpdateTime,jdbcType=TIMESTAMP},",
          "storage_deleted = #{storageDeleted,jdbcType=BIT}",
        "where storage_id = #{storageId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallStorage record);
}